package com.tf_cut.backend.seller.service;

import com.tf_cut.backend.common.service.CommonServiceImpl;
import com.tf_cut.backend.mapper.SellerAccountMapper;
import com.tf_cut.backend.seller.pojo.SellerAccount;
import com.tf_cut.backend.seller.repository.SellerAccountRepository;
import com.tf_cut.backend.seller.vo.SellerAndAccountVo;
import com.tf_cut.backend.util.ConfigSettingUtil;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Arrays;
import java.util.List;

import javax.annotation.Resource;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

@Service
@Transactional
public class SellerAccountServiceImpl extends CommonServiceImpl<SellerAndAccountVo, SellerAccount, String> implements SellerAccountService {

    @PersistenceContext
    private EntityManager em;
    @Autowired
    private SellerAccountRepository sellerAccountRepository;

    @Autowired
    private SellerAccountMapper sellerAccountMapper;
    

    @Override
    public SellerAndAccountVo findSellerAccountByCondition(SellerAndAccountVo sellerAndAccountVo) {
        return sellerAccountMapper.findSellerAccount(sellerAndAccountVo);
    }

	@Override	
	public String findByServiceId(String sellerId) {
		return sellerAccountMapper.findByServiceId(sellerId);
	}

	@Override
	public Integer queryBySellerName(String sellerName, String sellerCompanyName) {
		return sellerAccountMapper.queryBySellerName(sellerName,sellerCompanyName);
	}

	@Override
	public SellerAndAccountVo queryBySellerId(String appIdKey) {
		return sellerAccountMapper.queryBySellerId(appIdKey);
	}

	@Override
	public String findByType(String serviceType) {
		List<String> lis = Arrays.asList(serviceType.split(","));
		List<String> serviceTypes = sellerAccountMapper.findByConfig(lis);
		String ids = String.join(",", serviceTypes);
		return ids;
	}
}
